package com.mymorningroutine;
import android.os.*;
import java.util.*;
import com.mymorningroutine.obj.*;
import android.widget.*;
import android.view.View.*;
import android.widget.AdapterView.*;
import android.view.*;
import android.content.*;
import android.util.*;

public class DialogRoutines extends android.app.Activity
{

	private ArrayList<Routine> routinesList;
	private ListView listView;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO: Implement this method
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dialog_activities);
		listView = (ListView) findViewById(android.R.id.list);
		loadRoutines();
		listView.setOnItemClickListener(new OnItemClickListener(){

				@Override
				public void onItemClick(AdapterView<?> p1, View p2, int position, long p4)
				{
					Intent intent = new Intent();
					intent.putExtra("routineId",p2.getId());
					setResult(3, intent);
					finish();
				}


			});
	}

	public void loadRoutines()
	{
		routinesList = Singleton.getRoutineTable(getApplicationContext()).getRoutines();
		listView.setAdapter(new RoutinesAdapter(this, R.layout.list_goal_item, routinesList));
	}


}
